#!/bin/sh


> tmp$$
cat CompositeStocks |sort |uniq  |while read stock
do
    export star=`curl -stderr "http://caps.fool.com/Ticker.aspx?ticker=$stock" |grep -A 2 "CAPS Rating:" |egrep -o "[a-z_]+.gif" |cut -d'.' -f1 |cut -d'_' -f3`
    echo $stock $star >> tmp$$
done

cat tmp$$ |grep five |awk '{print $1}' > MotleyFoolLongList
cat tmp$$ |grep one  |awk '{print $1}' > MotleyFoolShortList

